package simpleflink;

import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class FilterFunctionTest {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStream<String> dataStream = env.readTextFile("data/user.txt");

        DataStream<String> filterStream = dataStream.filter(new FlinkFilter());

        filterStream.print();

        env.execute();
    }

    public static class FlinkFilter implements FilterFunction<String>{
        public boolean filter(String s) throws Exception {
            return s.contains("1");
        }
    }
}
